[NET] back: Fix bug in 12262:ac2097d71e06dbbf77279af10d6ae7359d921ab0.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 16 Nov 2006 08:56:58 +0000 (08:56 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Thu, 16 Nov 2006 08:56:58 +0000 (08:56 +0000)
Pointed out by Jan Beulich.
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/netback/netback.c

index c4fb3e438359210fc9535d694b2e3af1fb8ed2d2..19e0cdef17ec29e23e7f56b7f310c787c6083176 100644 (file)
@@ -825,7 +825,9 @@ static void tx_add_credit(netif_t *netif)
        max_burst = max(max_burst, netif->credit_bytes);
 
        /* Take care that adding a new chunk of credit doesn't wrap to zero. */
-       max_credit = max(netif->remaining_credit + netif->credit_bytes, ~0UL);
+       max_credit = netif->remaining_credit + netif->credit_bytes;
+       if (max_credit < netif->remaining_credit)
+               max_credit = ULONG_MAX; /* wrapped: clamp to ULONG_MAX */
 
        netif->remaining_credit = min(max_credit, max_burst);
 }